package com.biz.primus.ms.auth.dao.vo;

import com.biz.primus.ms.auth.dao.po.MenuGroup;
import com.biz.primus.ms.auth.dao.po.MenuItem;
import com.biz.primus.ms.auth.dao.po.Resource;

import java.util.Set;

import static com.google.common.collect.Sets.newHashSet;

/**
 * Created by defei on 9/4/17.
 */
public class ParsedAuthorityVO {

    private Set<MenuGroup> menuGroups = newHashSet();

    private Set<MenuItem> menuItems = newHashSet();

    private Set<Resource> resources = newHashSet();

    public void addMenuGroup(MenuGroup menuGroup) {
        if (menuGroup != null)
            this.menuGroups.add(menuGroup);
    }

    public void addMenuItem(MenuItem menuItem) {
        if (menuItem != null)
            this.menuItems.add(menuItem);
    }

    public void addResource(Resource resource) {
        if (resource != null)
            this.resources.add(resource);
    }

    public void add(ParsedAuthorityVO parsedAuthorityVO) {

        if(parsedAuthorityVO == null){
            return;
        }
        this.menuGroups.addAll(parsedAuthorityVO.getMenuGroups());
        this.menuItems.addAll(parsedAuthorityVO.getMenuItems());
        this.resources.addAll(parsedAuthorityVO.getResources());
    }

    /**
     * {@linkplain ParsedAuthorityVO#menuGroups}
     */
    public Set<MenuGroup> getMenuGroups() {
        return menuGroups;
    }

    /**
     * {@linkplain ParsedAuthorityVO#menuItems}
     */
    public Set<MenuItem> getMenuItems() {
        return menuItems;
    }

    /**
     * {@linkplain ParsedAuthorityVO#resources}
     */
    public Set<Resource> getResources() {
        return resources;
    }
}
